package cn.kgc.kgceurekauserconsumer1.controller;

import cn.kgc.kgceurekauserconsumer1.client.RestUserServiceClient;
import org.springframework.web.bind.annotation.*;
import pojo.User;

import javax.annotation.Resource;


/**
 * @author geQiang
 * @version 1.0
 * @date 2019/4/14
 * @description cn.kgc.kgceurekauserconsumer1.controller
 */
@RestController
public class LoginController {
    @Resource
    private RestUserServiceClient restUserServiceCilent;

    @RequestMapping("/login")
    public String login(
            @RequestParam(value = "username", defaultValue = "", required = false) String username,
            @RequestParam(value = "password", defaultValue = "", required = false) String password
    ) {

        //测试多次调用provider，负载分发情况
        for (int i = 0; i < 10; i++) {
            System.out.println("我是8082");
            restUserServiceCilent.login(username, password);
        }
        return "hello 合肥科海";
    }

    @RequestMapping(value = "/loginByUser", method = RequestMethod.POST)
    public User loginByUser(@RequestBody User user) {
        return restUserServiceCilent.loginByUser(user);
    }

}